package com.mc.common.base;

/**
 * 接口返回接口封装
 */
public class ResultUtil {

    /**
     * 调用成功
     *
     * @param data 返回参数
     * @return
     */
    public static final BaseResponse getSuccessResultData(final Object data) {
        BaseResponse baseResponse = new BaseResponse();
        baseResponse.setSuccess(true);
        baseResponse.setCode(String.valueOf(BaseConstant.STATUS_OK_CODE));
        baseResponse.setBody(data);
        return baseResponse;
    }

    /**
     * 调用成功 无返回参数
     *
     * @return
     */
    public static final BaseResponse getSuccessResultData() {
        return getSuccessResultData(null);
    }

    /**
     * 调用失败
     *
     * @param errorMessages 返回错误信息
     * @return
     */
    public static final BaseResponse getFailureResultData(String errorMessages) {
        BaseResponse baseResponse = new BaseResponse();
        baseResponse.setCode(String.valueOf(BaseConstant.STATUS_FAIlURE_CODE));
        baseResponse.setMessage(errorMessages);
        return baseResponse;
    }

    /**
     * 调用失败 默认返回调用失败
     *
     * @return
     */
    public static final BaseResponse getFailureResultData() {
        return getFailureResultData(BaseConstant.STATUS_FAIlURE_MSG);
    }


}
